<template>
  <div class="recommend">
    <h2 class="title">商品推荐</h2>
    <swiper class="swiper" :options="swiperOption">
      <swiper-slide v-for="item of recommend" :key="item.goodsId">
        <router-link :to="{path:'/details',query:{id:item.goodsId}}">
          <van-image :src="$filterImage(item.image)" lazy-load>
            <template v-slot:loading>
              <van-loading type="spinner" size="20" />
            </template>
          </van-image>
        </router-link>
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
import "swiper/css/swiper.css";
export default {
  components: {
    Swiper,
    SwiperSlide
  },
  data() {
    return {
      swiperOption: {
        slidesPerView: 3,
        spaceBetween: 30
      },
      recommend: []
    };
  },
  created() {
    this.$eventBus.$on("getIndexInfo", res => {
      this.recommend = res.recommend;
    });
  }
};
</script>

<style lang="scss">
    @import "@/style/home/recommend"
</style>